package ltd.hxya.novel.common.utils;

import java.sql.*;

public class HiveUtils {


    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        Connection connection = DriverManager.getConnection("jdbc:hive2://192.168.65.39:10000/novel_row_data","root","root");
        return connection;
    }

    public void insert(){

    }

   public static Statement getStatement() throws SQLException, ClassNotFoundException {
        return getConnection().createStatement();
   }

   public static PreparedStatement getPreparedStatement(String sql) throws SQLException, ClassNotFoundException {
        return getConnection().prepareStatement(sql);
   }

   public static void otherOperator(String sql) throws SQLException, ClassNotFoundException {
        getPreparedStatement(sql).execute();
   }

   public static ResultSet select(String sql) throws SQLException, ClassNotFoundException {
        return getPreparedStatement(sql).executeQuery();
   }


}
